<template>
  <a-button type="primary" danger @click="showPromiseDelete">删除</a-button>
</template>

<script setup>

import {message, Modal} from "ant-design-vue";
import {createVNode, inject, reactive} from "vue";
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
import request from "@/utils/request";
import {useStore} from "vuex";
import 'ant-design-vue/dist/antd.css'

const store = useStore()
const iinject=inject('reload')

const showPromiseDelete = () => {
  if (store.getters.getSelectedEssaySet.length === 0) {
    message.warning("你倒是选一个阿大哥")
  } else {
    console.log(store.getters.getSelectedEssaySet)
    Modal.confirm({
      title: '确定删除选中吗？鑫哥',
      icon: createVNode(ExclamationCircleOutlined),
      // content: 'Some descriptions',
      okText: '把这些删了',
      okType: 'danger',
      cancelText: '算了',

      onOk() {
        console.log('OK');
        request.post("essay/admin/delete", store.getters.getSelectedEssaySet).then(res=>{
          console.log(res)
          iinject()

        })

      },

      onCancel() {
        console.log('Cancel');
      },

    });
  }

};
</script>
